package cn.sc.summer.rabbitmq.runner;

import cn.sc.summer.constant.project.ProjectConstant;
import cn.sc.summer.rabbitmq.service.RabbitService;
import cn.sc.summer.redis.util.NacosInstancesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 类名：mq发送消息至网关，开始预热服务
 *
 * @author a-xin
 * @date 2023/8/25 14:31
 */
@Slf4j
@Component
public class RabbitRunner implements CommandLineRunner {

    @Resource
    protected RabbitService rabbitService;

    /**
     * Callback used to run the bean.
     *
     * @param args incoming main method arguments
     * @throws Exception on error
     */
    @Override
    public void run(String... args) throws Exception {
        rabbitService.registerServer(ProjectConstant.SERVER_NAME, NacosInstancesService.getServerNacosAddress());
    }
}
